import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created by mac on 2017/5/31.
 */
public class MyOD {
    public static void main(String[] args) throws IOException {
        MyOD.dump(
                new FileInputStream(args[0])
        );
    }

    public static void dump(InputStream src)
            throws IOException {
        try (InputStream input = src) {
            byte[] buf = new byte[50];
            int k = input.read(buf, 0, buf.length);     //读取100byte
            //System.out.println(new String(buf));      将这100byte打印出来，测试

            int[] in = new int[buf.length];             //新建数组，储存其ASCII码值
            for (int i = 0; i < in.length; i++) {       //将byte的8位于1111_1111与
                in[i] = buf[i]&0xff;                    //得到ASCII码值
            }

            int flat = 0,temp = 0,j = 0;            //状态控制变量flag，循环控制变量temp,j

            do {
                if(flat == 0) {
                    while(temp < buf.length) {
                        if(buf[temp] != 0 && buf[temp] != 10) {          //如果有数据,并且不是换行则打印
                            System.out.printf("%c   ",buf[temp]);
                            temp++;
                            if(temp%16 == 0 && temp!=0){        //如果打印了16个就换行,flat置1，换到ASCII输出
                                System.out.println();
                                flat = 1;
                                break;
                            }
                        }
                        else {
                            System.out.println();                   //buf[]遍历结束就转到ASCII把剩下的输出了
                            flat = 1;
                            break;
                        }
                    }
                }
                else if(flat == 1) {
                    while(j < in.length) {
                        if(in[j]!=0 && in[j] != 10) {                   //如果有数据,并且不是换行则打印
                            System.out.printf(Integer.toString(in[j], 0x10));
                            System.out.printf("  ");
                            j++;
                            if(j%16 == 0 && j!=0) {                 //如果打印了16个就换行,flat置0，换到BYTE输出
                                System.out.println();
                                flat = 0;
                                break;
                            }
                        }
                        else {
                            flat = 3;                               //所有的数据输出完毕,flat置3,跳出大循环,结束程序
                            break;
                        }
                    }
                }
                else System.out.println("wrong!");
                if(flat == 3) break;
            }while(flat == 0 || flat == 1);                         //只要flat不为3,继续循环

        }
    }
}
